package com.medusa.aps.business.modules.modeling.model.input;

import com.medusa.aps.business.modules.modeling.mp.entity.ProcessEquipment;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.experimental.Accessors;

import static com.medusa.aps.business.model.constant.DigitConstants.*;

/**
 * 工艺工序设备
 *
 * @author miskw
 * @date 2023/9/2
 */
@Data
@Accessors(chain = true)
public class ProcessEquipmentDTO {
    /**
     * 设备id
     */
    @Schema(description = "设备id")
    @NotNull(message = "设备id不能为空")
    private Long equipmentId;
    /**
     * 设备编码
     */
    @Schema(description = "设备编码")
    @NotNull(message = "设备编码不能为空")
    private String equipmentCode;

    /**
     * 生产节拍
     */
    @Schema(description = "生产节拍")
    @NotNull(message = "生产节拍不能为空")
    @Max(value = 9999999L, message = "生产节拍" + SEVEN_DIGIT_RANGE_PROMPTS)
    @Min(value = 1, message = "生产节拍" + SEVEN_DIGIT_RANGE_PROMPTS)
    private Long productionBeat;
    /**
     * 辅助资料id
     */
    @Schema(description = "辅助资料id")
    private Integer auxiliaryDataId;
    /**
     * 辅助资料编码
     */
    @Schema(description = "辅助资料编码")
    private String auxiliaryDataCoding;
    /**
     * 加工批量
     */
    @Schema(description = "加工批量")
    @NotNull(message = "加工批量不能为空")
    @Max(value = 9999999999L, message = "加工批量" + TEN_DIGIT_RANGE_PROMPTS)
    @Min(value = 1, message = "加工批量" + TEN_DIGIT_RANGE_PROMPTS)
    private Long processingBatch;

    public ProcessEquipment toProcessEquipment(Integer processProcessId, Integer processId, Integer processRouteId, Long materialId, String materialCode) {
        return new ProcessEquipment()
                .setEquipmentId(equipmentId)
                .setEquipmentCode(equipmentCode)
                .setProductionBeat(productionBeat)
                .setProcessId(processId)
                .setProcessRouteId(processRouteId)
                .setAuxiliaryDataId(auxiliaryDataId)
                .setAuxiliaryDataCoding(auxiliaryDataCoding)
                .setProcessingBatch(processingBatch)
                .setProcessProcessId(processProcessId)
                .setMaterialId(materialId)
                .setMaterialCode(materialCode);
    }
}
